﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ws="clr-namespace:Creventive.Wpf.ShellFactory.Workspace">
    <Style TargetType="ws:CloseButton">
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="UseLayoutRounding" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ws:CloseButton">
                    <ControlTemplate.Resources>
                        <RadialGradientBrush x:Key="IdleBackdropBrush" Center="0.5,0.5" RadiusX="1" RadiusY="0.75">
                            <GradientStop Offset="0.2" Color="#e00000" />
                            <GradientStop Offset="1" Color="#882319" />
                        </RadialGradientBrush>
                    </ControlTemplate.Resources>
                    <Grid Background="Transparent">
                        <Border x:Name="outerGlow" Background="#FF0000" CornerRadius="3" Opacity="0" IsHitTestVisible="False">
                            <Border.Effect>
                                <DropShadowEffect Color="#FF0000" ShadowDepth="0" Opacity="1" BlurRadius="8" />
                            </Border.Effect>
                        </Border>
                        <Border x:Name="backdrop" CornerRadius="3" IsHitTestVisible="False" Background="{StaticResource IdleBackdropBrush}" />
                        <Border CornerRadius="2" BorderBrush="#80FFFFFF" BorderThickness="1" Margin="1" IsHitTestVisible="False"/>
                        <Border x:Name="innerGlow" CornerRadius="2" BorderThickness="1" Margin="1" Opacity="0" IsHitTestVisible="False">
                            <Border.Background>
                                <RadialGradientBrush Center="0.5,1" GradientOrigin="0.5,1" RadiusX="1.3" RadiusY="0.4">
                                    <GradientStop Offset="0" Color="#ffffc0" />
                                    <GradientStop Offset="0.3" Color="#80ffff80" />
                                    <GradientStop Offset="1" Color="#00ffff00" />
                                </RadialGradientBrush>
                            </Border.Background>
                        </Border>
                        <Border x:Name="pressedPanel" CornerRadius="3" IsHitTestVisible="False" Visibility="Hidden" Margin="2">
                            <Border.Background>
                                <RadialGradientBrush>
                                    <GradientStop Offset="0.2" Color="#40000000" />
                                    <GradientStop Offset="1" Color="#A0000000" />
                                </RadialGradientBrush>
                            </Border.Background>
                        </Border>
                        <Border CornerRadius="3" IsHitTestVisible="False">
                            <Border.Background>
                                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                    <GradientStop Offset="0.0" Color="#b9ffffff" />
                                    <GradientStop Offset="0.5" Color="#98ffffff" />
                                    <GradientStop Offset="0.5" Color="#70ffffff" />
                                    <GradientStop Offset="1.0" Color="#8bffffff" />
                                </LinearGradientBrush>
                            </Border.Background>
                        </Border>
                        <Border CornerRadius="3" BorderBrush="#60000000" BorderThickness="1" IsHitTestVisible="False"/>
                        <Image x:Name="glyph" Width="11" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                            <Image.Source>
                                <DrawingImage>
                                    <DrawingImage.Drawing>
                                        <GeometryDrawing Brush="White">
                                            <GeometryDrawing.Pen>
                                                <Pen Brush="#C0000000" Thickness="1" />
                                            </GeometryDrawing.Pen>
                                            <GeometryDrawing.Geometry>
                                                <PathGeometry Figures="M1,0 h3 l2,3 l2,-3 h3 l1,1 l-3,4 v1 l3,4 l-1,1 h-3 l-2,-3 l-2,3 h-3 l-1,-1 l3,-4 v-1 l-3,-4 z" />
                                            </GeometryDrawing.Geometry>
                                        </GeometryDrawing>
                                    </DrawingImage.Drawing>
                                </DrawingImage>
                            </Image.Source>
                        </Image>

                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="innerGlow" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.1" />
                                        <DoubleAnimation Storyboard.TargetName="outerGlow" Storyboard.TargetProperty="Opacity" To="0.5" Duration="0:0:0.1" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="innerGlow" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.5" FillBehavior="Stop" />
                                        <DoubleAnimation Storyboard.TargetName="outerGlow" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.5" FillBehavior="Stop" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="pressedPanel" Property="Visibility" Value="Visible" />
                            <Setter TargetName="glyph" Property="RenderTransform">
                                <Setter.Value>
                                    <TranslateTransform Y="1" />
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>